package com.cskaoyan.dbutils;

import com.cskaoyan.datasource.opensource.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.ColumnListHandler;
import org.apache.commons.dbutils.handlers.ScalarHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * 创建日期: 2022/06/05 17:36
 *
 * @author ciggar
 *
 * ScalarHandler
 */
public class DBUtilsDemo10 {


    public static void main(String[] args) throws SQLException {

        // 创建一个QueryRunner ， 传入数据库连接池
        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());

        Long count =  queryRunner.query("select count(*) from cskaoyan",
                new ScalarHandler<>());

        System.out.println(count);
    }
}
